package com.fund.user.base;


import com.fund.feign.bean.TUser;
import com.fund.security.base.BaseAppController;
import com.fund.security.dto.UserInfo;
import com.fund.user.config.GlobalExceptionHandler;
import org.springframework.beans.BeanUtils;

/**
 * 项目名称:      hera-web
 * 模块名称:
 * 说明:
 * JDK 版本:      1.8
 * 作者(@author): cqian
 * 创建日期:      2022/2/11 10:45
 */
public class BaseController extends BaseAppController {

    public UserInfo getUserInfo() {
        if (contextHolder.getContext().getUser() == null) {
            throw new GlobalExceptionHandler("请重新登录");
        }
        return contextHolder.getContext().getUser();
    }

    public TUser getTUser() {
        if (contextHolder.getContext().getUser() == null) {
            throw new GlobalExceptionHandler("请重新登录");
        }
        UserInfo user = contextHolder.getContext().getUser();
        TUser tUser = new TUser();
        BeanUtils.copyProperties(user,tUser);
        return tUser;
    }

}
